package com.xieyong.leetcode;

import java.util.Arrays;

public class Leetcode3333 {
    public static void main(String[] args) {
        Leetcode3333 leetcode3333 = new Leetcode3333();
        String word = "aaabbb";
        int k = 3;
        int i = leetcode3333.possibleStringCount(word, k);
        System.out.println(i);
    }


    public int possibleStringCount(String word, int k) {
        int n = word.length();
        int maxlen = n - k;
        int[] list = new int[26];
        Arrays.fill(list, 0);
        for (char c : word.toCharArray()) {
            list[c - 'a']++;
        }
        int res = 0, mod = (int) 1e9 + 7,count = 0;
        for (int i : list) {
            if (i > 1) {
                res += (Math.min(maxlen,i) + 1) % mod;
                count++;
            }
        }
        return (res - count + 1) % mod;
    }
}
